import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
} from '@nestjs/common';
import { EmploymentService } from './employment.service';
import { CreateEmploymentDto } from './dto/create-employment.dto';
import { UpdateEmploymentDto } from './dto/update-employment.dto';
import { Employment } from './entities/employment.entity';
import { SearchPagesDto } from './dto/search-pages.dto';

@Controller('/admin/xinwentongzhi')
export class EmploymentController {
  constructor(private readonly employmentService: EmploymentService) {}

  @Post()
  create(@Body() createEmploymentDto: CreateEmploymentDto) {
    return this.employmentService.create(createEmploymentDto);
  }

  @Post('/page')
  findAllPage(@Body() pages: SearchPagesDto) {
    return this.employmentService.findAllPage(pages);
  }

  @Post('/deleteList')
  deleteList(@Body() data: { list: Employment[] }) {
    return this.employmentService.batchRemove(data.list.map((item) => item.id));
  }

  @Get()
  findAll() {
    return this.employmentService.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.employmentService.findOne(+id);
  }

  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body() updateEmploymentDto: UpdateEmploymentDto,
  ) {
    return this.employmentService.update(+id, updateEmploymentDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.employmentService.remove(+id);
  }
}
